<?php

namespace App\Admin\Controllers\Game;

use App\Admin\Controllers\Controller;
use App\Admin\Filters\Game\GameSonFilter;
use App\Admin\Models\Game\GameSon;
use App\Admin\Requests\Game\GameSonRequest;
use App\Admin\Resources\Game\GameSonResource;
use Illuminate\Http\Request;

class GameSonController extends Controller
{
    public function index(GameSonFilter $filter)
    {
        $gameSons = GameSon::query()
            ->filter($filter)
            ->paginate();

        return $this->ok(GameSonResource::collection($gameSons));
    }

    public function create()
    {
        return $this->ok();
    }

    public function store(GameSonRequest $request)
    {
        $inputs = $request->validated();
        $gameSon = GameSon::create($inputs);

        return $this->created(GameSonResource::make($gameSon));
    }

    public function edit(Request $request, GameSon $gameSon)
    {
        return $this->ok(GameSonResource::make($gameSon));
    }

    public function update(GameSonRequest $request, GameSon $gameSon)
    {
        $inputs = $request->validated();
        $gameSon->update($inputs);

        return $this->created(GameSonResource::make($gameSon));
    }

    public function destroy(GameSon $gameSon)
    {
        $gameSon->delete();
        return $this->noContent();
    }
}
